home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 2
/
Aminet AMIGA CDROM (1994)(Walnut Creek)[Feb 1994][W.O. 44790-1].iso
/
Aminet
/
util
/
libs
/
MultiReq.lha
/
MultiReq
/
C
/
TestProg.c
< prev
Wrap
C/C++ Source or Header
|
1992-11-12
|
5KB
|
226 lines
extern APTR OpenLibrary();
extern struct Message *GetMsg();
extern struct Window *OpenWindow();
extern UWORD FileRequester();
extern void InitFileReq(), FreeFileReq();
extern struct TextFont *OpenFont();
/* Defined in TestGads.c */
extern struct Gadget ScreenGadg;
extern void CreateDisplay();
extern struct Screen *GetScreen();
/* The Library Bases */
struct MultiReqBase *MultiReqBase;
struct GfxBase *GfxBase;
struct IntuitionBase *IntuitionBase;
/* some important pointers */
static struct FileReq *fr;
static BOOL ScrnType;
static BOOL ScrnMode;
static struct Window *TestWindow;
static struct RastPort *rp;
static struct IntuiMessage *IntMsg;
/* my functions */
static void OpenAll(), CloseAll(), DoIDCMP(), CheckGadget(), OpenMultiReq(), SetGadgets();
/* my window */
static struct NewWindow NewTestWindow =
{
62,0,
516,200,
0,1,
GADGETUP+CLOSEWINDOW,
WINDOWDRAG+WINDOWDEPTH+WINDOWCLOSE+ACTIVATE+NOCAREREFRESH,
&ScreenGadg,
NULL,
(UBYTE *)"MultiReq Testprogram v1.00",
NULL,
NULL,
0,0,
0,0,
WBENCHSCREEN
};
/* T80 Font */
static struct TextFont *T80Font;
struct TextAttr Topaz80 =
{
(STRPTR)"topaz.font",
TOPAZ_EIGHTY,
FS_NORMAL,
FPF_ROMFONT
};
void main()
{
OpenAll();
DoIDCMP();
CloseAll();
}
static void OpenAll()
{
if(!(IntuitionBase=(struct IntuitionBase *)OpenLibrary("intuition.library",0L)))
{
puts("Can't open intuition.library !");
CloseAll();
}
if(!(GfxBase=(struct GfxBase *)OpenLibrary("graphics.library",0L)))
{
puts("Can't open graphics.library !");
CloseAll();
}
if(!(MultiReqBase=(struct MultiReqBase *)OpenLibrary("multireq.library",0L)))
{
puts("Can't open multireq.library !");
CloseAll();
}
if(!(T80Font=OpenFont(&Topaz80)))
{
puts("Can't open topaz.font !");
CloseAll();
};
InitFileReq(&fr,2L);
if(!fr)
{
puts("Unable to alloc Memory for the FileReq-structure !");
CloseAll();
}
SetGadgetBuffers(fr);
if(!(TestWindow=OpenWindow(&NewTestWindow)))
{
puts("Can't open test window !");
CloseAll();
}
rp=TestWindow->RPort;
SetFont(rp,T80Font); /* I need no other fonts !! */
CreateDisplay(TestWindow,rp);
SetGadgets();
}
static void CloseAll()
{
if(T80Font) CloseFont(T80Font);
if(TestWindow) CloseWindow(TestWindow);
if(fr) FreeFileReq(&fr);
if(MultiReqBase) CloseLibrary(MultiReqBase);
if(GfxBase) CloseLibrary(GfxBase);
if(IntuitionBase) CloseLibrary(IntuitionBase);
exit(0);
}
static void DoIDCMP()
{
register ULONG Class;
register UWORD GadgetID;
register struct Gadget *GadgetPtr;
FOREVER
{
if(!(IntMsg=(struct IntuiMessage *)GetMsg(TestWindow->UserPort)))
{
Wait(1L << TestWindow->UserPort->mp_SigBit);
continue;
}
Class=IntMsg->Class;
if(GadgetPtr=(struct Gadget *)IntMsg->IAddress) /* avoid enforcer hits */
GadgetID=GadgetPtr->GadgetID;
else
GadgetID=0;
ReplyMsg(IntMsg);
if(Class==CLOSEWINDOW)
break;
else if(Class==GADGETUP)
CheckGadget(GadgetPtr,GadgetID);
}
}
static void CheckGadget(GadgetPtr,GadgetID)
register struct Gadget *GadgetPtr;
register USHORT GadgetID;
{
switch(GadgetID)
{
case ID_FILEREQ:
OpenMultiReq();
break;
case ID_SCREEN:
ScrnType^=(BOOL)TRUE;
SetScreenType(TestWindow,rp,ScrnType,ScrnMode);
break;
case ID_SCRMODE:
ScrnMode^=(BOOL)TRUE;
SetScreenMode(rp,ScrnMode);
break;
case ID_DIRECTORY:
fr->ActiveList^=1;
SetDirectory(rp,(UWORD)fr->ActiveList);
break;
case ID_INFO:
fr->ShowInfo^=1;
SetInfo(rp,(UWORD)fr->ShowInfo);
break;
case ID_AUTO1:
case ID_AUTO2:
fr->FileList[GadgetID-ID_AUTO1].AutoRead^=1;
SetAutoRead(TestWindow,rp,GadgetPtr,fr->FileList[GadgetID-ID_AUTO1].AutoRead);
break;
case ID_CURRENT1:
case ID_CURRENT2:
GetCurrent(TestWindow,fr,GadgetID-ID_CURRENT1);
break;
}
}
static void OpenMultiReq()
{
register struct Screen *scrn;
GetEdge(fr);
scrn=GetScreen(ScrnType,ScrnMode);
FileRequester(fr,scrn); /* don't need returned status, cause it's */
/* also stored in fr->ReturnStatus */
if(scrn) CloseScreen(scrn);
RefreshGadgets(&ScreenGadg,TestWindow,NULL);
SetGadgets();
WriteStatus(rp,fr);
}
static void SetGadgets()
{
SetScreenType(TestWindow,rp,ScrnType,ScrnMode);
SetDirectory(rp,(UWORD)fr->ActiveList);
SetInfo(rp,(UWORD)fr->ShowInfo);
SetAutoGadgets(TestWindow,rp,fr);
SetEdge(TestWindow,fr);
}